<!--
 * @Author: your name
 * @Date: 2021-12-24 10:09:31
 * @LastEditTime: 2021-12-26 19:50:40
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \vue\vue-douban-pc\src\views\Books.vue
-->
<template>
  <div class="home">
    <div class="books-block">
      <span>
        <h1>书籍推荐</h1>
      </span>
      <el-carousel :interval="4000" type="card" height="77vh">
        <el-carousel-item v-for="book in bookList" :key="book.book_id">
          <router-link :to="{name: 'BooksPlay',params: {id: book.book_id}}"><img :src="baseUrl + book.b_image" alt=""></router-link>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="books-recommend">
      <span>受关注榜</span>
      <div class="recommend-body">
        <ul>
          <li v-for="list in bookList" :key="list.book_id" @click="href(list.book_id)">{{ list.b_title }}</li>
        </ul>
      </div>
    </div>
  </div>
</template>
<script>
import mixin from "../utils/mixin";
export default {
  name: 'Home',
  mixins: [mixin],
  data() {
    return {
      bookList: [],
    }
  },
  components: {
  },
  created() {
    this.getBooksList();
  },
  methods: {
    getBooksList() {
      this.axios.get(
        "/getBooksHomeList")
        .then((res) => {
          console.log(res.data);
          this.bookList = res.data;
          console.log(this.bookList);
        })
    },
    href(id){
      this.$router.push({path:"/booksplay",name: "BooksPlay",params: {id: id}})
    }
  },
}
</script>

<style lang="scss">


.home {
  position: relative;
  .books-block {
    width: 50%;
    position: absolute;
    top: 20px;
    left: 25%;
    h1 {
      font-weight: 500;
      font-size: 30px;
      color: rgb(255, 255, 255);
    }
    .el-carousel {
      width: 100%;
      img{
        width: 100%;
        height: 100%;
      }
    }
  }
  .books-recommend {
    width: 220px;
    position: fixed;
    right: 0;
    bottom: 5px;
    border-radius: 5px;
    border: 1px solid white;
    font-size: 14px;
    background-color: rgba(9, 190, 121, 0.1);
    span {
      display: block;
      padding: 12px 20px;
      font-size: 15px;
      color: #f1b92c;
    }
    .recommend-body{
      border-top: 1px solid white;
      color: #b8d6d0;
      ul{
        padding: 25px;
      }
      li{
        list-style-type: decimal;
        padding: 5px;
      }
      li:hover{
        color: orangered;
        cursor: pointer;
        transition: all 0.5s ease;
      }
    }
  }
}
html {
  overflow-x: hidden;
}
</style>